const float weight[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);

uniform sampler2D texture;
uniform int status;
varying vec2 vTexCoord;
void main() {
	vec4 baseColor = texture2D(texture, vTexCoord);
	if(status == 2) {
		float brightness = dot(baseColor.rgb, vec3(0.2126, 0.7152, 0.0722));
	    if(brightness > 1.0) {
	    	gl_FragColor = baseColor;
	    } else {
	    	discard;
	    }
	} else {
		vec2 tex_offset = 1.0 / textureSize(texture, 0); // gets size of single texel
		vec3 result = baseColor.rgb * weight[0]; // current fragment's contribution
		if(status == 0) {
			for(int i = 1; i < 5; i ++) {
	            result += texture2D(texture, vTexCoord + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
	            result += texture2D(texture, vTexCoord - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
	        }
		} else {
			for(int i = 1; i < 5; i ++) {
	            result += texture2D(texture, vTexCoord + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
	            result += texture2D(texture, vTexCoord - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
	        }
		}
		gl_FragColor = vec4(result, 1.0);
	}
}